#!/bin/sh
#===========================================================================
#
#   Run Surveyor Tests - Linux and OSX
#
#   Note the Windows runtests.bat is more complete, this focuses on 
#   executing the python test scripts
#
#===========================================================================
# Copyright 2011, Matt Peloquin. This file is part of Code Surveyor, 
# covered under GNU GPL v3 and is distributed WITHOUT ANY WARRANTY
#===========================================================================

fail()
    {
    export SET SURVEYOR_RUN_TEST_SUCCESS=
    echo
    echo      =============================
    echo             TESTING FAILED
    echo      =============================
    echo
    exit
    }

success()
    {
    export SET SURVEYOR_RUN_TEST_SUCCESS=1
    echo
    echo      =============================
    echo          All Tests Succeeded!
    echo      =============================
    exit
    }

echo 
echo               Starting Surveyor Tests
echo 
echo          MAKE SURE TestFiles.zip is UNZIPPED

rm  -r -f output
mkdir output

echo
echo +++++++++++++++++++++++++++++++++++++++++++
echo  Python Script Tests
echo +++++++++++++++++++++++++++++++++++++++++++
echo

python ./scripts/run_scripts.py unit
if [ $? -ne 0 ] 
then
    fail
fi

python ./scripts/run_scripts.py module
if [ $? -ne 0 ] 
then
    fail
fi


python ./scripts/run_scripts.py system
if [ $? -ne 0 ] 
then
    fail
fi

#
# Oracle test is too brittle across platforms, as the order of files processed
# will vary. Maybe write a surveyor csv compare util to do measure comparison,
# while would make Oracle much less brittle than file compare
#
#echo
#echo +++++++++++++++++++++++++++++++++++++++++++
#echo  Checking Oracle
#echo +++++++++++++++++++++++++++++++++++++++++++
#echo

# Compare oracle files to output for a log
#for file in TestOracle/*
#do
#    diff $file ./output/$(basename $file) > ./output/OracleTest_Output.txt
#    if [ $? -ne 0 ] 
#    then
#        fail
#    fi

success


